package org.linphone.activity;

import java.util.List;

import com.leehuubsd.yiyanzb.R;
import com.umeng.analytics.MobclickAgent;

import org.linphone.Adapter.AppManagerAdapter;
import org.linphone.Bean.AppInfo;
import org.linphone.util.AppInfoProvider;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings.System;
import android.telephony.TelephonyManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class SafeActivity extends Activity implements OnClickListener {
	private ListView lv_app_manager;
	private AppManagerAdapter adapter;
	private TextView 设备型号, 安卓版本, base_title_btn;
	private ImageView back;
	private List<AppInfo> appInfos;
	public void onResume() {
		super.onResume();
		MobclickAgent.onResume(this);
	}

	public void onPause() {
		super.onPause();
		MobclickAgent.onPause(this);
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_safe);
		lv_app_manager = (ListView) findViewById(R.id.lv_app_manager);
		back = (ImageView) findViewById(R.id.setting_back);
		设备型号 = (TextView) findViewById(R.id.android_x);
		安卓版本 = (TextView) findViewById(R.id.android_v);
		base_title_btn = (TextView) findViewById(R.id.base_title_btn);
		设备型号.setText("设备型号:  " + android.os.Build.MODEL);
		安卓版本.setText("Android 版本:  " + android.os.Build.VERSION.RELEASE);
		base_title_btn.setOnClickListener(this);
		back.setOnClickListener(this);

		appInfos = AppInfoProvider.getAppInfos(this);
		adapter = new AppManagerAdapter(appInfos, this);
		lv_app_manager.setAdapter(adapter);

	}

	@SuppressLint("NewApi")
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.base_title_btn:
			StringBuilder sb = new StringBuilder();
			sb.append(设备型号.getText().toString() + "\n"
					+ 安卓版本.getText().toString() + "\n");
			for (int i = 0; i < appInfos.size(); i++) {
				sb.append(appInfos.get(i).getName()+"\t");
			}
			// 设备型号.getText().toString()+"\n"+安卓版本.getText().toString()+"\n"+appInfos
			// 复制
			ClipboardManager copy = (ClipboardManager) SafeActivity.this
					.getSystemService(Context.CLIPBOARD_SERVICE);
			copy.setText(设备型号.getText().toString() + "\n"+ 安卓版本.getText().toString() + "\n" + sb);
			Toast.makeText(SafeActivity.this, "复制成功", 0).show();
			break;
		case R.id.setting_back:
			finish();
			break;
		}
	}

}
